package com.restaurant.springboot.entity;

import javax.persistence.*;
import java.math.BigDecimal;
import java.sql.Timestamp;
import java.util.Objects;

@Entity
@Table(name = "coupon_series", schema = "restaurant", catalog = "")
public class CouponSeriesEntity {

    private int id;
    private String name;
    private BigDecimal quota;
    private BigDecimal mixLimit;
    //优惠券开始时间
    private Timestamp startTime;
    //优惠券结束时间
    private Timestamp endTime;
    //领取优惠券时的有效时间,以天为单位
    private int effectiveTime;
    //优惠券是否有效
    private boolean Enabled;

    public CouponSeriesEntity(String name, BigDecimal quota, BigDecimal mixLimit, Timestamp startTime, Timestamp endTime, int effectiveTime, boolean enabled) {
        this.name = name;
        this.quota = quota;
        this.mixLimit = mixLimit;
        this.startTime = startTime;
        this.endTime = endTime;
        this.effectiveTime = effectiveTime;
        Enabled = enabled;
    }

    public CouponSeriesEntity() {
    }

    @Id
    @Column(name = "id")
    @GeneratedValue
    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    @Basic
    @Column(name = "name")
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Basic
    @Column(name = "quota")
    public BigDecimal getQuota() {
        return quota;
    }

    public void setQuota(BigDecimal quota) {
        this.quota = quota;
    }

    @Basic
    @Column(name = "mix_limit")
    public BigDecimal getMixLimit() {
        return mixLimit;
    }

    public void setMixLimit(BigDecimal mixLimit) {
        this.mixLimit = mixLimit;
    }


    @Basic
    @Column(name = "effective_time")
    public int getEffectiveTime() {
        return effectiveTime;
    }

    public void setEffectiveTime(int effectiveTime) {
        this.effectiveTime = effectiveTime;
    }


    @Basic
    @Column(name = "start_time")
    public Timestamp getStartTime() {
        return startTime;
    }

    public void setStartTime(Timestamp startTime) {
        this.startTime = startTime;
    }


    @Basic
    @Column(name = "end_time")
    public Timestamp getEndTime() {
        return endTime;
    }

    public void setEndTime(Timestamp endTime) {
        this.endTime = endTime;
    }

    @Basic
    @Column(name = "enable")
    public boolean isEnabled() {
        return Enabled;
    }

    public void setEnabled(boolean enabled) {
        Enabled = enabled;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        CouponSeriesEntity that = (CouponSeriesEntity) o;
        return id == that.id &&
                effectiveTime == that.effectiveTime &&
                Enabled == that.Enabled &&
                Objects.equals(name, that.name) &&
                Objects.equals(quota, that.quota) &&
                Objects.equals(mixLimit, that.mixLimit) &&
                Objects.equals(startTime, that.startTime) &&
                Objects.equals(endTime, that.endTime);
    }

    @Override
    public int hashCode() {
        return Objects.hash(id, name, quota, mixLimit, startTime, endTime, effectiveTime, Enabled);
    }
}
